package cn.com.dcsgo.service.impl;

import cn.com.dcsgo.mapper.ActivitySkuMapper;
import cn.com.dcsgo.model.activity.ActivitySku;
import cn.com.dcsgo.model.order.CartInfo;
import cn.com.dcsgo.service.ActivitySkuService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ActivitySkuServiceImpl
 *
 * @author Dcsgo
 * @since 10/5/2025 下午 7:55
 */
@Service
public class ActivitySkuServiceImpl extends ServiceImpl<ActivitySkuMapper, ActivitySku> implements ActivitySkuService {
    @Override
    public List<ActivitySku> getList(List<CartInfo> cartItems) {
        if (CollectionUtils.isEmpty(cartItems)) {
            return new ArrayList<>(0);
        }
        return baseMapper.selectList(
                new LambdaQueryWrapper<ActivitySku>()
                        .in(ActivitySku::getSkuId,
                                cartItems.stream().map(CartInfo::getSkuId).collect(Collectors.toList()))
        );
    }
}
